import { useRef, useEffect } from "react"
function Editing({ todo }) {
    const {isEditing,title,modifyTodoTitle} = todo;
    const ref = useRef(null)
    useEffect(()=>{
     if(isEditing){
        ref.current.focus()
     }
    },[isEditing])
    return (
        <input className="edit" onBlur={()=>{modifyTodoTitle(ref.current.value)}} ref={ref} defaultValue={title} />
    )
}

export default Editing